<?php

namespace common\models\kingdee;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\kingdee\PmUser;

/**
 * PmUserSearch represents the model behind the search form about `common\models\kingdee\PmUser`.
 */
class PmUserSearch extends PmUser
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['FID', 'FNUMBER', 'FNAME_L1', 'FNAME_L2', 'FNAME_L3', 'FDESCRIPTION_L1', 'FDESCRIPTION_L2', 'FDESCRIPTION_L3', 'FPASSWORD', 'FEFFECTIVEDATE', 'FINVALIDATIONDATE', 'FDEFAULTLOCALE', 'FGROUPID', 'FPERSONID', 'FSECURITYID', 'FPWEFFECTIVEDATE', 'FLOCKEDTIME', 'FDEFORGUNITID', 'FCONTROLUNITID', 'FCREATORID', 'FCREATETIME', 'FLASTUPDATEUSERID', 'FLASTUPDATETIME', 'FCUSTOMERID', 'FSUPPLIERID', 'FMAINROLEID', 'FPWDHISSTR', 'FREFERID', 'FCELL', 'FBACKUPEMAIL', 'FHOMEPHONE', 'FOFFICEPHONE', 'FEMAIL', 'FADNUMBER', 'FNAMEPINYIN', 'FNAMESHORTPINYIN', 'FPINYIN', 'FSHORTPINYIN', 'FUID'], 'safe'],
            [['FTYPE', 'FISDELETE', 'FISLOCKED', 'FFORBIDDEN', 'FISREGISTER', 'FERRCOUNT', 'FISBIZADMIN', 'FISCHANGEDPW', 'FAGENTUSER', 'FLOGINAUTHORWAY', 'FISACTIVATE', 'FISSYNTOCLOUD'], 'integer'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = PmUser::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'FTYPE' => $this->FTYPE,
            'FISDELETE' => $this->FISDELETE,
            'FISLOCKED' => $this->FISLOCKED,
            'FFORBIDDEN' => $this->FFORBIDDEN,
            'FEFFECTIVEDATE' => $this->FEFFECTIVEDATE,
            'FINVALIDATIONDATE' => $this->FINVALIDATIONDATE,
            'FISREGISTER' => $this->FISREGISTER,
            'FERRCOUNT' => $this->FERRCOUNT,
            'FPWEFFECTIVEDATE' => $this->FPWEFFECTIVEDATE,
            'FLOCKEDTIME' => $this->FLOCKEDTIME,
            'FISBIZADMIN' => $this->FISBIZADMIN,
            'FISCHANGEDPW' => $this->FISCHANGEDPW,
            'FCREATETIME' => $this->FCREATETIME,
            'FLASTUPDATETIME' => $this->FLASTUPDATETIME,
            'FAGENTUSER' => $this->FAGENTUSER,
            'FLOGINAUTHORWAY' => $this->FLOGINAUTHORWAY,
            'FISACTIVATE' => $this->FISACTIVATE,
            'FISSYNTOCLOUD' => $this->FISSYNTOCLOUD,
        ]);

        $query->andFilterWhere(['like', 'FID', $this->FID])
            ->andFilterWhere(['like', 'FNUMBER', $this->FNUMBER])
            ->andFilterWhere(['like', 'FNAME_L1', $this->FNAME_L1])
            ->andFilterWhere(['like', 'FNAME_L2', $this->FNAME_L2])
            ->andFilterWhere(['like', 'FNAME_L3', $this->FNAME_L3])
            ->andFilterWhere(['like', 'FDESCRIPTION_L1', $this->FDESCRIPTION_L1])
            ->andFilterWhere(['like', 'FDESCRIPTION_L2', $this->FDESCRIPTION_L2])
            ->andFilterWhere(['like', 'FDESCRIPTION_L3', $this->FDESCRIPTION_L3])
            ->andFilterWhere(['like', 'FPASSWORD', $this->FPASSWORD])
            ->andFilterWhere(['like', 'FDEFAULTLOCALE', $this->FDEFAULTLOCALE])
            ->andFilterWhere(['like', 'FGROUPID', $this->FGROUPID])
            ->andFilterWhere(['like', 'FPERSONID', $this->FPERSONID])
            ->andFilterWhere(['like', 'FSECURITYID', $this->FSECURITYID])
            ->andFilterWhere(['like', 'FDEFORGUNITID', $this->FDEFORGUNITID])
            ->andFilterWhere(['like', 'FCONTROLUNITID', $this->FCONTROLUNITID])
            ->andFilterWhere(['like', 'FCREATORID', $this->FCREATORID])
            ->andFilterWhere(['like', 'FLASTUPDATEUSERID', $this->FLASTUPDATEUSERID])
            ->andFilterWhere(['like', 'FCUSTOMERID', $this->FCUSTOMERID])
            ->andFilterWhere(['like', 'FSUPPLIERID', $this->FSUPPLIERID])
            ->andFilterWhere(['like', 'FMAINROLEID', $this->FMAINROLEID])
            ->andFilterWhere(['like', 'FPWDHISSTR', $this->FPWDHISSTR])
            ->andFilterWhere(['like', 'FREFERID', $this->FREFERID])
            ->andFilterWhere(['like', 'FCELL', $this->FCELL])
            ->andFilterWhere(['like', 'FBACKUPEMAIL', $this->FBACKUPEMAIL])
            ->andFilterWhere(['like', 'FHOMEPHONE', $this->FHOMEPHONE])
            ->andFilterWhere(['like', 'FOFFICEPHONE', $this->FOFFICEPHONE])
            ->andFilterWhere(['like', 'FEMAIL', $this->FEMAIL])
            ->andFilterWhere(['like', 'FADNUMBER', $this->FADNUMBER])
            ->andFilterWhere(['like', 'FNAMEPINYIN', $this->FNAMEPINYIN])
            ->andFilterWhere(['like', 'FNAMESHORTPINYIN', $this->FNAMESHORTPINYIN])
            ->andFilterWhere(['like', 'FPINYIN', $this->FPINYIN])
            ->andFilterWhere(['like', 'FSHORTPINYIN', $this->FSHORTPINYIN])
            ->andFilterWhere(['like', 'FUID', $this->FUID]);

        return $dataProvider;
    }
}
